<template>
  <el-drawer
    :visible.sync="dialogVisible"
    :size="size"
    v-bind="$attrs"
    :destroy-on-close="destroyOnClose"
    :wrapperClosable="true"
    :append-to-body="appendToBody"
    :direction="direction"
    :show-close="showClose"
    @close="$emit('close')"
    @closed="$emit('closed')"
  >
    <template v-slot:title>
      <div class="s-drawer">
        <div>{{ title }}</div>
        <div @click="$emit('close')">X</div>
      </div>
    </template>
    <slot></slot>
  </el-drawer>
</template>

<script>
export default {
  name: "skyDrawer",
  props: {
    title: {
      type: String,
      default: "",
    },
    visible: {
      type: Boolean,
      default: true,
    },
    size: {
      type: String,
      default: "30%",
    },
    appendToBody: {
      type: Boolean,
      default: true,
    },
    direction: {
      type: String,
      default: "rtl",
    },
    showClose: {
      type: Boolean,
      default: false,
    },
    destroyOnClose: {
      type: Boolean,
      default: true,
    },
  },
  computed: {
    dialogVisible: {
      get() {
        return this.visible;
      },
      set(val) {
        this.$emit("updateVisible", val);
      },
    },
  },
};
</script>

<style lang="less" scoped>
.s-drawer {
  position: absolute;
  width: 100%;
  top: 0;
  left: 0;
  height: 49px;
  background-color: #1786d8;
  display: flex;
  align-items: center;
  flex: 1;
  justify-content: space-between;
  padding: 20px;
  > div {
    font-size: 18px;
    color: white;
    &:nth-child(2) {
      width: 12px;
      height: 14px;
      &:hover {
        cursor: pointer;
      }
      img {
        width: 100%;
        height: 100%;
      }
    }
  }
}
</style>
